@model zhangmenren.Models.ViewModle.WorksModel
<h2>Index</h2>
<div class="bg-gray">
	<header class="mui-bar mui-bar-nav head-bar-nav">
		<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left" href="javascript:history.back(-1);"></a>
		<h1 class="mui-title">订单支付</h1>
	</header>
	<!--DOM -->
	<div class="mui-content bg-gray">

		<div class="mui-input-row pay-order-input-row">
			<label style="height: 40px; line-height: 22px;">费用总计</label>
			<input type="text" value=" @(Model.Price>0?"¥"+Model.Price+"元":"0")" readonly="readonly">
		</div>

		<!---->
		<div class="alert-box alert-course-pay" id="alert-course-pay">
			<h5 class="mui-text-left">
				请选择支付方式
			</h5>
			<ul class="mui-table-view mui-table-view-radio">
				<li class="mui-table-view-cell mui-selected alertPay-icon alertPay-icon3">
					<a class="mui-navigate-right" href="javascript:;">
						支付宝支付
					</a>
				</li>
				<li class="mui-table-view-cell alertPay-icon alertPay-icon2">
					<a class="mui-navigate-right" href="javascript:;">
						微信支付
					</a>
				</li>
			</ul>
			<br />
			<p class="mui-text-center">
				<img src="/images/pau-order-ht-icon.png" height="14px" />&nbsp;同意并接受<span style="color: #00a5bb;">《共享条例》</span>
			</p>
			<br />
			<div class="mui-content-padded link-href" data-href='pay-success.html'>
				<input type="button" class="mui-btn mui-btn-yellow mui-btn-block alert-pay-btn" value="确认支付">
			</div>
			<br />
		</div>
		<!---->
	</div>


</div>

@section Scripts{
<script>

		var paytype = 1;

		$(".alertPay-icon2").click(function () {
			paytype = 0;
			$(this).addClass("mui-selected");
			$(".alertPay-icon3").removeClass("mui-selected");
		})

		$(".alertPay-icon3").click(function () {
			paytype = 1;
			$(this).addClass("mui-selected");
			$(".alertPay-icon2").removeClass("mui-selected");
		})


		$(".alert-pay-btn").click(function () {
			$.ajax({
				type: "post",
				url: '@Url.Action("SubOrder")',
				data: { payType: paytype, workid:@Model.Id },
				success: function (result) {
					if (result.state == "ok") {

						if (result.amount > 0) {
							jsBridge.pay({
								channel: result.channel,              //integer, 支付渠道, 0微信，1支付宝
								orderid: result.orderid, //string(64), 订单号
								title: result.title,  //string(128), 订单名称
								amount: result.amount         //decimal，支付金额（元）
							}, function (succ) {
								if (succ) {
									$.ajax({
								type: "post",
								url: '@Url.Action("PaySuccessAjax")',
								data: { orderId: result.orderid },
								success: function (res) {
									if (res.state == "ok") {
										location.href = '@Url.Action("PaySuccess")';
									}
								}
							});
								} else {
									alert("支付失败或取消了支付");
								}
							});
						} else {
							$.ajax({
								type: "post",
								url: '@Url.Action("PaySuccessAjax")',
								data: { orderId: result.orderid },
								success: function (res) {
									if (res.state == "ok") {
										location.href = '@Url.Action("PaySuccess")';
									}
								}
							});
						}


					}
				}
			})

		})







</script>
}